package com.zyfdroid.bigdialerkit.voiceassistant;

import android.app.assist.AssistContent;
import android.app.assist.AssistStructure;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.service.voice.VoiceInteractionSession;
import android.service.voice.VoiceInteractionSessionService;
import android.util.Log;
import com.zyfdroid.bigdialerkit.MainActivity;

public class InteractionSessionService extends VoiceInteractionSessionService {
    @Override
    public VoiceInteractionSession onNewSession(Bundle args) {
        return new InteractionSession(this);
    }

    public static class InteractionSession extends VoiceInteractionSession {

        public InteractionSession(Context context) {
            super(context);
        }

        @Override
        public void onCreate() {
            super.onCreate();

            Log.d("VOA", "OnCreate: ");

        }

        @Override
        public void onShow(Bundle args, int showFlags) {
            super.onShow(args, showFlags);
            Log.d("VOA", "onShow: ");
            Intent launchIntent = null;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                launchIntent = new Intent(getContext(), MainActivity.class);
                launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getContext().startActivity(launchIntent);

                hide();
            }
        }

        @Override
        public void onHandleAssist(Bundle data, AssistStructure structure, AssistContent content) {
            super.onHandleAssist(data, structure, content);

        }
    }


    }
